package org.apache.solr.spelling;

import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import org.apache.lucene.analysis.Token;

/**
 * Passes the entire query string to the configured analyzer as-is.
 **/
public class SuggestQueryConverter extends SpellingQueryConverter {

    @Override
    public Collection<Token> convert(String original) {

        if (original == null) { // this can happen with q.alt = and no query
            return Collections.emptyList();
        }

        Collection<Token> result = new ArrayList<>();
        try {
            analyze(result, new StringReader(original), 0, 0);
        }
        catch (IOException e) {
            throw new RuntimeException(e);
        }
        return result;
    }
}
